package br.ufpi.componets.conversor;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.ResourceBundle;

import br.com.caelum.vraptor.Convert;
import br.com.caelum.vraptor.Converter;
import br.com.caelum.vraptor.ioc.ApplicationScoped;

@Convert(Date.class)
@ApplicationScoped
/**
 * Convert hours and minutes for the standard HH:mm and transforming in date
 * @author Cleiton
 *
 */
public class DateConvert implements Converter<Date> {

	@Override
	public Date convert(String value, Class<? extends Date> type, ResourceBundle bundle) {
		try {
			return new SimpleDateFormat("HH:mm").parse(value);
		} catch (ParseException e) {
			e.printStackTrace();
			return null;
		}
	}

}
